package jdbc3_25.homework;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;

public class JDBCDemo07 {
    public static void main(String[] args) {
        try(Connection connection = DBUtil01.getConnection()){
            Statement statement = connection.createStatement();
            String sql = "SELECT id,username,password,nickname " +
                    "FROM user " +
                    "WHERE username=? AND password=?";
            PreparedStatement ps = connection.prepareStatement(sql);
            ps.setString(1,"qqq");
            ps.setString(2,"123123");
            ResultSet rs = ps.executeQuery();
            System.out.println(rs.next()?"登录成功":"登录失败");
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
